/*
 * DEMSurfaceTest.cpp
 *
 *  Created on: 07/mar/2013
 *      Author: lordmzn
 */

#include <gtest/gtest.h>
#include <vector>
#include "MOLEM/DEMSurface.h"

namespace MOLEMTests {

class DEMSurfaceTest : public ::testing::Test {

public:
	DEMSurfaceTest() {
		nr1 = 13;
		nc1 = 25;
	}
	unsigned int nr1;
	unsigned int nc1;
};

TEST_F(DEMSurfaceTest, ConstructorsTest) {
	// 13 x 25
	std::vector<double> fakeValues(nr1 * nc1, 2.0);
	MOLEM::DEMSurface surf(nr1, nc1);
	double sumZvals = surf.getSumZvalues();
	// test not very clean since rely on Element behaviour :|
	ASSERT_EQ((double) (MOLEM::ELEMENT_Z_DEFAULT_VALUE *
			nr1 * nc1), sumZvals) << "13x25 sum of z values not working";
	// 1 x 25
	std::vector<double> fakeValues1(1 * nc1, 120.0);
	MOLEM::DEMSurface surf1(1, nc1);
	sumZvals = surf1.getSumZvalues();
	ASSERT_EQ((double) (MOLEM::ELEMENT_Z_DEFAULT_VALUE * 1 *
			nc1), sumZvals)<< "1x25 sum of z values not working";
}

TEST_F(DEMSurfaceTest, ZValsTest) {
	// 13 x 25
	std::vector<double> fakeValues(nr1 * nc1, 2.0);
	MOLEM::DEMSurface surf(nr1, nc1);
	ASSERT_EQ(MOLEM::VALUES_CORRECTLY_SET,
			surf.setValues(fakeValues))<< "13x25 set values not working";
	// reset values
	fakeValues = std::vector<double>(nr1 * nc1, 5.0);
	ASSERT_EQ(MOLEM::VALUES_CORRECTLY_SET,
			surf.setValues(fakeValues))<< "13x25 reset values not working";
	double sumZvals = surf.getSumZvalues();
	ASSERT_EQ((double) (5 * nr1 * nc1), sumZvals)<< "13x25 resum of z values not working";
	// 1 x 25
	std::vector<double> fakeValues1(1 * nc1, 120.0);
	MOLEM::DEMSurface surf1(1, nc1);
	ASSERT_EQ(MOLEM::VALUES_CORRECTLY_SET,
			surf1.setValues(fakeValues1))<< "1x25 set values not working";
}
} /* namespace MOLEMTests */
